package me.zhengjie.ffmpeg;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;

public class RuntimeUtils {

    public static void run(List<String> command){
        try {
            BufferedReader br = null;
            try {
                ProcessBuilder builder = new ProcessBuilder();
                builder.command(command);
                builder.redirectErrorStream(true);
                Process process = builder.start();
                br = new BufferedReader(new InputStreamReader(process.getInputStream()));
                String line = null;
                while ((line = br.readLine()) != null) {
                    System.out.println(line);
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (br != null) {
                    try {
                        br.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
